package demo5;

/**
 * @Author 12629
 * @Description：
 */
class Animal {
    public String name;
    public int age;
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        //System.out.println("Animal(String name,int age)......");
    }
    public void eat() {
        System.out.println(name +" 正在吃饭...");
    }
}

class Dog extends Animal {
    public Dog(String name,int age) {
        super(name,age);
        //System.out.println("Dog(String name,int age)......");
    }
    public void bark() {
        System.out.println(name +" 正在汪汪叫...");
    }

    public void eat() {
        System.out.println(name+" 正在吃狗粮...");
    }
}
class Bird extends Animal {
    public Bird(String name,int age) {
        super(name,age);
        //System.out.println("Bird(String name,int age)......");
    }
    public void fly() {
        System.out.println(name+" 正在飞...");
    }

    /*public void eat() {
        System.out.println(name+" 正在吃鸟粮...");
    }*/

    @Override
    public void eat() {
        System.out.println(name+" 正在吃鸟粮...");
    }
}

public class Test {

    public static void func1(Animal animal) {
        animal.eat();
    }
    public static void main(String[] args) {
        Animal animal1 = new Dog("旺财",3);
        //animal.eat();
        //animal.bark();
        Animal animal2 = new Bird("小鸟",3);
        func1(animal1);
        func1(animal2);
    }

    public static Animal func2() {
        Dog dog = new Dog("旺财",3);
        return dog;
    }
    public static void main1(String[] args) {

        Animal animal = func2();

        /*Animal animal = new Animal("小动物",1);
        animal.eat();*/

        /*Dog dog = new Dog("旺财",3);

        Animal animal = dog;*/
        Dog dog = new Dog("旺财",3);
        func1(dog);

        //Animal animal = new Dog("旺财",3);

    }
}
